#include <bits/stdc++.h>
using namespace std;

const int N = 110;
bitset<N> a[N];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int n, i, j;
	bool x;
	cin >> n;
	for (i = 1; i <= n; ++i)
	{
		for (j = 1; j <= n; ++j)
		{
			cin >> x;
			a[i][j] = x;
		}
	}
	for (j = 1; j <= n; ++j) // 借用j点
	{
		for (i = 1; i <= n; ++i)
		{
			if (a[i][j])
			{
				a[i] |= a[j];
			}
		}
	}
	for (i = 1; i <= n; ++i)
	{
		for (j = 1; j <= n; ++j)
		{
			cout << a[i][j] << ' ';
		}
		cout << '\n';
	}
	return 0;
}
